################################################
##Replication Files for "How to Estimate Public Support for Political Violence and Why It Matters: 
#Impact of Sampling, Engagement Checks, and Question Phrasing"

##Each of the main calls below creates or recreates a specific file or table
##In the paper.

##If you have any questions specifically about this code, please contact the second author.
###########################################################################################

###Load neccessary packages
library(tidyverse)
library(haven)
library(survey)


#Start by re-creating WTGN's code and findings

#All credit for these materials belongs to: Westwood, Grimmer, Taylor and Nall. 
#Westwood, Sean; Justin Grimmer; Matthew Tyler; Clayton Nall, 2022, "Replication Data for: 
#Current Research Overstates American Support for Political Violence", https://doi.org/10.7910/DVN/ZEHO8E, 
#Harvard Dataverse, V1, UNF:6:VJ6STyJ885T9gn+zeDvKmA== [fileUNF]

#Files retrieved 17-July-2025 from <https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/ZEHO8E>

setwd("WGTN/code")
source("main.R")

#Swap to folder with our code and data
setwd("../../")

#This cleans up input data, and applies survey weighting
source("process.R")

#Table 1 is just a set of estimates from existing work
#Please see the supplementary materials for how these were derived,
#as well as references for the values

#Figure 1 plots impact of engagement in existing studies
source("F1.R")

#Figure 2 is just a screen grab of the text of the vignette.
#contact the authors for the original survey firm questionaire

#Figure 3 is a screen grab of the survey experiment.
#contact the authors for the original survey firm questionaire

#Figure 4 is a screen grab of the second survey experiment.
#contact the authors for the original survey firm questionaire

#Table 2 gives response/non-response rates
#The final print version is re-formatted, but these provide same numbers
source("T2.R")

#Figure 5 shows the impact of non-response on a probability sample
source("F5.R")

#Table 3 provides numeric information on support and strong support
#the final print version is slightly re-formatted, but these provide same numbers
source("T3.R")

#Figure 6 presents graphical results of question wording experiment 1
source("F6.R")

#Table 4 presents results of question wording experiment 1 in tabular form
source("T4.R")

#Table 5 Estimates ATE's for question wording experiment 1 in tabular form
source("T5.R")

#Figure 7 presents graphical results of second question wording experiment
source("F7.R")

#Table 6 presents results of second question wording experiment in tabular form
source("T6.R")

#Table 7 presents ATE's of second question wording experiment. 
source("T7.R")



